package p270jp.pxv.android.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.BackStackRecord;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import java.util.Objects;
import p014ae.AbstractActivityC0178w3;
import p014ae.View$OnClickListenerC0151s;
import p018ai.PixivSettings;
import p047bg.C1124a;
import p079cl.SearchTopPresenter;
import p109dj.ScrollableToTop;
import p134ei.AnalyticsScreenName;
import p134ei.PixivAnalytics;
import p162fl.WorkTypeRepository;
import p209hg.SearchTopContract;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.constant.ContentType;
import p270jp.pxv.android.legacy.constant.SearchTarget;
import p270jp.pxv.android.topLevel.presentation.TopLevelStore;
import p314lg.ActivitySearchTopBinding;
import p325m0.MutabilityOwnership;
import p370ni.StartUpScreen;
import p374nm.ToolbarMenuView;
import p547uh.RecommendedUserFragment;
import p547uh.SearchIllustRecyclerFragment;
import p547uh.SearchNovelRecyclerFragment;
import p551ul.TopLevelStoreExtension;
import p625xi.LegacyNavigation;
import p639y6.C7292h;
import p639y6.C7301s;

/* compiled from: SearchTopActivity.kt */
/* renamed from: jp.pxv.android.activity.SearchTopActivity */
/* loaded from: classes2.dex */
public final class SearchTopActivity extends AbstractActivityC0178w3 implements SearchTopContract {

    /* renamed from: o0 */
    public static final /* synthetic */ int f18675o0;

    /* renamed from: j0 */
    public SearchTopPresenter f18676j0;

    /* renamed from: k0 */
    public ActivitySearchTopBinding f18677k0;

    /* renamed from: l0 */
    public WorkTypeRepository f18678l0;

    /* renamed from: m0 */
    public PixivSettings f18679m0;

    /* renamed from: n0 */
    public LegacyNavigation f18680n0;

    @Override // p209hg.SearchTopContract
    /* renamed from: J */
    public void mo4696J() {
        BackStackRecord cVar = new BackStackRecord(m11131K0());
        cVar.m11165j(R.id.type_fragment_container, new SearchNovelRecyclerFragment());
        cVar.mo11171d();
    }

    @Override // p209hg.SearchTopContract
    /* renamed from: a */
    public void mo4695a() {
        Fragment E = m11131K0().m11280E(R.id.type_fragment_container);
        ScrollableToTop eVar = E instanceof ScrollableToTop ? (ScrollableToTop) E : null;
        if (eVar != null) {
            eVar.mo1600a();
        }
    }

    @Override // p209hg.SearchTopContract
    /* renamed from: b0 */
    public void mo4694b0() {
        BackStackRecord cVar = new BackStackRecord(m11131K0());
        cVar.m11165j(R.id.type_fragment_container, new SearchIllustRecyclerFragment());
        cVar.mo11171d();
    }

    @Override // p209hg.SearchTopContract
    /* renamed from: c */
    public void mo4693c(ContentType contentType) {
        MutabilityOwnership.m3745m(contentType, "contentType");
        startActivity(SearchResultActivity.m4710e1(this, contentType, "", SearchTarget.PARTIAL_MATCH_FOR_TAGS));
    }

    @Override // p014ae.TopLevelActivity, p270jp.pxv.android.activity.AbstractActivityC4151b, p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ViewDataBinding d = DataBindingUtil.m11369d(this, R.layout.activity_search_top);
        MutabilityOwnership.m3746l(d, "setContentView(this, R.layout.activity_search_top)");
        ActivitySearchTopBinding r1Var = (ActivitySearchTopBinding) d;
        this.f18677k0 = r1Var;
        C1124a.m10196R(this, r1Var.f22203t, "");
        PixivAnalytics eVar = this.f18757A;
        PixivSettings bVar = this.f18679m0;
        if (bVar != null) {
            WorkTypeRepository eVar2 = this.f18678l0;
            if (eVar2 != null) {
                this.f18676j0 = new SearchTopPresenter(this, this, eVar, bVar, eVar2);
                m11131K0().m11251d0("fragment_request_key_charcoal_dialog_fragment", this, new C7301s(this, 6));
                TopLevelStore f1 = m12131f1();
                FragmentManager K0 = m11131K0();
                MutabilityOwnership.m3746l(K0, "supportFragmentManager");
                LegacyNavigation aVar = this.f18680n0;
                if (aVar != null) {
                    TopLevelStoreExtension.m1380a(f1, this, K0, this, this, aVar);
                    ActivitySearchTopBinding r1Var2 = this.f18677k0;
                    if (r1Var2 != null) {
                        r1Var2.f22202s.setOnSelectSegmentListener(new C7292h(this, 7));
                        SearchTopPresenter lVar = this.f18676j0;
                        if (lVar != null) {
                            lVar.f5590b.m12120h(StartUpScreen.SEARCH);
                            lVar.f5593e.mo4692v0(lVar.f5594f.getResources().getStringArray(R.array.illustmanga_novel_user), lVar.f5591c.m6287b());
                            ToolbarMenuView q0Var = new ToolbarMenuView(this);
                            q0Var.setSelectedItem(2);
                            Toolbar.C0375e eVar3 = new Toolbar.C0375e(-2, -1);
                            eVar3.f12463a = 8388613;
                            ActivitySearchTopBinding r1Var3 = this.f18677k0;
                            if (r1Var3 != null) {
                                r1Var3.f22203t.addView(q0Var, eVar3);
                                LayoutInflater from = LayoutInflater.from(this);
                                ActivitySearchTopBinding r1Var4 = this.f18677k0;
                                if (r1Var4 != null) {
                                    View inflate = from.inflate(R.layout.view_search_input_navigator, (ViewGroup) r1Var4.f22203t, false);
                                    Objects.requireNonNull(inflate, "null cannot be cast to non-null type androidx.appcompat.widget.AppCompatEditText");
                                    AppCompatEditText appCompatEditText = (AppCompatEditText) inflate;
                                    appCompatEditText.setKeyListener(null);
                                    appCompatEditText.setOnClickListener(new View$OnClickListenerC0151s(this, 4));
                                    Toolbar.C0375e eVar4 = new Toolbar.C0375e(-1, -1);
                                    int h = C1124a.m10184h(this, 1);
                                    int i = h * 4;
                                    eVar4.setMargins(0, i, h * 12, i);
                                    eVar4.f12463a = 8388611;
                                    ActivitySearchTopBinding r1Var5 = this.f18677k0;
                                    if (r1Var5 != null) {
                                        r1Var5.f22203t.addView(appCompatEditText, eVar4);
                                        m12132e1().m4555e();
                                        return;
                                    }
                                    MutabilityOwnership.m3737u("binding");
                                    throw null;
                                }
                                MutabilityOwnership.m3737u("binding");
                                throw null;
                            }
                            MutabilityOwnership.m3737u("binding");
                            throw null;
                        }
                        MutabilityOwnership.m3737u("presenter");
                        throw null;
                    }
                    MutabilityOwnership.m3737u("binding");
                    throw null;
                }
                MutabilityOwnership.m3737u("legacyNavigation");
                throw null;
            }
            MutabilityOwnership.m3737u("workTypeRepository");
            throw null;
        }
        MutabilityOwnership.m3737u("pixivSettings");
        throw null;
    }

    @Override // p014ae.TopLevelActivity, p014ae.AdActivity, p270jp.pxv.android.activity.BaseActivity, p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        SearchTopPresenter lVar = this.f18676j0;
        if (lVar != null) {
            lVar.f5593e = null;
        } else {
            MutabilityOwnership.m3737u("presenter");
            throw null;
        }
    }

    @Override // p209hg.SearchTopContract
    /* renamed from: v0 */
    public void mo4692v0(String[] strArr, int i) {
        MutabilityOwnership.m3745m(strArr, "titles");
        ActivitySearchTopBinding r1Var = this.f18677k0;
        if (r1Var != null) {
            r1Var.f22202s.m4467a(strArr, i);
        } else {
            MutabilityOwnership.m3737u("binding");
            throw null;
        }
    }

    @Override // p209hg.SearchTopContract
    /* renamed from: y0 */
    public void mo4691y0() {
        BackStackRecord cVar = new BackStackRecord(m11131K0());
        AnalyticsScreenName cVar2 = AnalyticsScreenName.SEARCH_USER;
        RecommendedUserFragment n7Var = new RecommendedUserFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("SCREEN_NAME", cVar2);
        n7Var.setArguments(bundle);
        cVar.m11165j(R.id.type_fragment_container, n7Var);
        cVar.mo11171d();
    }
}
